package com.datoucai.rpc;

import com.datoucai.api.MediaFeignService;
import com.datoucai.param.BaseResult;
import com.datoucai.param.HasLikeDto;
import com.datoucai.param.HasLikesParam;
import com.datoucai.param.MediaDetailInfoRes;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class MediaRpcService {

    @Resource
    private MediaFeignService  mediaFeignService;

    public MediaDetailInfoRes queryMediaInfoById(String mediaId) {
        BaseResult<MediaDetailInfoRes> mediaDetailInfoResBaseResult = mediaFeignService.queryMediaById(mediaId);
        if(mediaDetailInfoResBaseResult.getCode() != 0) {
            return null;
        }
        return mediaDetailInfoResBaseResult.getData();
    }

    public List<HasLikeDto> queryHasLikeByParam(HasLikesParam hasLikesParam) {
        BaseResult<List<HasLikeDto>> listBaseResult = mediaFeignService.hasLikes(hasLikesParam);
        if (listBaseResult.getCode() != 0) {
            return null;
        }
        return listBaseResult.getData();
    }
}